import type { TableColumn } from '@/components/core/dynamic-table';
import { getDate, parseTime } from '@/utils/telchina';
import { Tooltip } from 'ant-design-vue';
export type TableColumnItem = TableColumn;

export const processHisColumns: TableColumnItem[] = [
  // {
  //   title: '节点名称',
  //   key: 'name',
  //   hideInSearch: true,
  //   dataIndex: 'name',
  //   align: 'center',
  //   width: '70px',
  // },
  {
    title: '处理部门',
    key: 'todoDeptId',
    hideInSearch: true,
    dataIndex: 'deptName',
    align: 'center',
    width: '80px',
  },
  {
    title: '处理类型',
    key: 'operate',
    hideInSearch: true,
    dataIndex: 'operate',
    align: 'center',
    width: '80px',
  },
  {
    title: '审批意见',
    key: 'reason',
    hideInSearch: true,
    dataIndex: 'reason',
    align: 'center',
    width: '180px',
    customRender: ({ record }) => {
      return (
        <Tooltip title={record.reason}>
          <div class="ellipsis" style={{ float: 'left', maxWidth: '100%' }}>
            {record.reason}
          </div>
        </Tooltip>
      );
    },
  },
  {
    title: '处理人',
    key: 'todoUserId',
    hideInSearch: true,
    dataIndex: 'userName',
    align: 'center',
    width: '50px',
  },
  {
    title: '办理时间',
    hideInSearch: true,
    key: 'endTime',
    dataIndex: 'endTime',
    align: 'center',
    width: '80px',
    customRender: ({ record }) => {
      if (!record.endTime) {
        return '未审批';
      }
      return parseTime(record.endTime);
    },
  },
  {
    title: '用时',
    hideInSearch: true,
    key: 'endTime',
    dataIndex: 'endTime',
    align: 'center',
    width: '30px',
    customRender: ({ record }) => {
      if (!record.endTime) {
        return '--';
      }
      return getDate(record.endTime - record.createTime);
    },
  },
];
